package business.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;

import vo.Paper;
import vo.Sentence;
import business.SentenceService;
import dao.SentenceDAO;

public class SentenceServiceImpl implements SentenceService {

	private SentenceDAO sentenceDao;

	public List<Sentence> getAll() {
		return sentenceDao.findAll();
	}

	@Required
	public void setSentenceDao(SentenceDAO sentenceDao) {
		this.sentenceDao = sentenceDao;
	}

	@Transactional
	public void insertSentence(Sentence sentence) {
		sentenceDao.create(sentence);
	}

	public List<Sentence> getByPaperId(long paperId) {
		return sentenceDao.findByPaperId(paperId);
	}

	// 分页
	public List<Sentence> getAll(int start, int pageSize) {
		return sentenceDao.findAll(start, pageSize);
	}

	public long getTotalCount() {
		return sentenceDao.findTotalCount();
	}

	// 关键字分页
	public List<Sentence> getByKeyword(int start, int pageSize,String keyword) {
		return sentenceDao.findByKeyword(start, pageSize,keyword);
	}

	public long getTotalCountByKeyword(String keyword) {
		return sentenceDao.findTotalCountByKeyword(keyword);
	}

	public List<Sentence> getByPaperId(int start, int pageSize, long paperId) {
		return sentenceDao.findByPaperId(start, pageSize, paperId);
	}

	public long getTotalCountByPaperId(long paperId) {
		return sentenceDao.findTotalCountByPaperId(paperId);
	}

	//按照类型分页
	public List<Sentence> getByType(int start, int pageSize, long type) {
		return sentenceDao.findByType(start, pageSize, type);
	}

	public long getTotalCountByType(long type) {
		return sentenceDao.findTotalCountByType(type);
	}

	//按照类型,关键字分页
	public List<Sentence> getByTypeKeyword(int start, int pageSize, long type,String keyword) {
		return sentenceDao.findByTypeKeyword(start, pageSize, type,keyword);
	}

	public long getTotalCountByTypeKeyword(long type,String keyword) {
		return sentenceDao.findTotalCountByTypeKeyword(type,keyword);
	}

}